/*****************************************************************************/
/*                  Perot Systems Framework                                  */
/*****************************************************************************/
/* Stored Procedure :: SetExceptionContext()                                 */
/* Set Context                                                               */
/*****************************************************************************/
/* Copyright (C) 2003, Perot Systems Corporation. All right reserved.        */
/* Developer: Dmitry Frenkel (dima.frenkel@ps.net)                           */
/* Started:  07/07/2003                                                      */
/*****************************************************************************/
/* Modifications                                                             */
/* Date       |  Author          | Description                               */
/*------------+------------------+-------------------------------------------*/
/*            |                  |                                           */
/*****************************************************************************/

/******************************************************************************/
/* Step 0. Preparations/Declarations                                          */
/******************************************************************************/
SET NOCOUNT OFF
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
GO

/******************************************************************************/
/* Step 1. Remove stored procedure if it already exists                       */
/******************************************************************************/
IF (SELECT OBJECT_ID('[DBO].[SetExceptionContext]')) IS NOT NULL
BEGIN
  DROP PROCEDURE [DBO].SetExceptionContext
END

GO

/*****************************************************************************/
/* Stored Procedure :: SetExceptionContext()                                 */
/*****************************************************************************/
/* Copyright (C) 2003, Perot Systems Corporation. All right reserved.        */
/* Developer: Dmitry Frenkel (dima.frenkel@ps.net)                           */
/* Started:  07/07/2003                                                      */
/*****************************************************************************/
CREATE PROCEDURE [DBO].SetExceptionContext( @ExceptionID BIGINT, 
                                            @Key VARCHAR(64),
                                            @Value VARCHAR(1024) )
AS  
BEGIN
	IF NOT EXISTS (select ExceptionID from ExceptionContexts where ExceptionID = @ExceptionID AND [Key] = @Key)
	BEGIN
	  INSERT INTO ExceptionContexts( ExceptionID, [Key], Value )
	  VALUES( @ExceptionID, @Key, @Value )
	END
END 
GO

/******************************************************************************/
/* Step 3. Assign appropriate permissions                                     */
/******************************************************************************/
GRANT EXECUTE ON [DBO].SetExceptionContext TO [Liberty_Users]
GO
-- Developers and Admins have permissions to execute through membership   